/*
 * Copyright (c) [2019] [lookang]
 *    [Software Name] is licensed under the Mulan PSL v1.
 *    You can use this software according to the terms and conditions of the Mulan PSL v1.
 *    You may obtain a copy of Mulan PSL v1 at:
 *       http://license.coscl.org.cn/MulanPSL
 *    THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 *    IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 *    PURPOSE.
 *    See the Mulan PSL v1 for more details.
 */

package com.lookang.demo.controller;

import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author liulekang
 * @date 2019/11/20
 */
@Slf4j
@RestController
public class ChoiceController {

    private static final String[] FOODS = new String[]{"盖浇饭", "砂锅", "大排档", "米线", "满汉全席", "西餐", "麻辣烫", "自助餐", "炒面", "快餐", "水果", "西北风", "馄饨", "火锅", "烧烤", "泡面", "速冻水饺", "日本料理", "涮羊肉", "味千拉面", "肯德基", "面包", "扬州炒饭", "自助餐", "茶餐厅", "海底捞", "咖啡", "比萨", "麦当劳", "兰州拉面", "沙县小吃", "烤鱼", "海鲜", "铁板烧", "韩国料理", "粥", "快餐", "萨莉亚", "桂林米粉", "东南亚菜", "甜点", "农家菜", "川菜", "粤菜", "湘菜", "本帮菜", "竹笋烤肉"};
    private static final String[] BREAKFAST_FOODS = new String[]{"面包","蛋糕","荷包蛋","烧饼","饽饽","油条","馄饨","火腿","面条","小笼包","","玉米粥","肉包","山东煎饼","饺子","煎蛋","烧卖","生煎","锅贴","包子","酸奶","苹果","梨","香蕉","皮蛋瘦肉粥","蛋挞","南瓜粥","煎饼","玉米糊","泡面","粥","馒头","燕麦片","水煮蛋","米粉","豆浆","牛奶","花卷","豆腐脑","煎饼果子","小米粥","黑米糕","鸡蛋饼","牛奶布丁","水果沙拉","鸡蛋羹","南瓜馅饼","鸡蛋灌饼","奶香小馒头","汉堡包","披萨","八宝粥","三明治","蛋包饭","豆沙红薯饼","驴肉火烧","粥","粢饭糕","蒸饺","白粥",};
    private static List<String> FOOD_MENU = Lists.newArrayList(FOODS);

    @RequestMapping(value = "/choiceFood", method = RequestMethod.GET)
    public String chiceFood(@RequestParam("mealsFlag") int mealsFlag) {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        int index = random.nextInt(FOOD_MENU.size());
        String food = "";
        if (mealsFlag == 0 || mealsFlag == 3) {
            List<String> strings = Arrays.asList(BREAKFAST_FOODS);
            food = strings.get(index);
        }else{
            food = FOOD_MENU.get(index);
        }
        return food;
    }

}
